package cn.kshost.zqyg.manager.controller;

import cn.kshost.zqyg.manager.service.SysMenuService;
import cn.kshost.zqyg.model.entity.system.SysMenu;
import cn.kshost.zqyg.model.vo.common.Result;
import cn.kshost.zqyg.model.vo.common.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/system/sysMenu")
public class SysMenuController {
    @Autowired
    SysMenuService sysMenuService;

    @Operation(summary = "查询菜单节点")
    @GetMapping("/findNodes")
    public Result<List<SysMenu>> findNodes() {
       List<SysMenu> nodes =  sysMenuService.finNodes();
       return Result.build(nodes, ResultCodeEnum.SUCCESS);
    }

    @Operation(summary = "添加菜单")
    @PostMapping("/addMenu")
    public Result addMenu(@RequestBody SysMenu sysMenu) {
        sysMenuService.addMenu(sysMenu);
        return  Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @Operation(summary = "删除菜单")
    @DeleteMapping("/removeMenu")
    public Result removeMenu(@RequestBody SysMenu sysMenu) {
        sysMenuService.removeMenu(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }

    @Operation(summary ="更新菜单")
    @PutMapping("/updataMenu")
    public Result updateMenu(@RequestBody SysMenu sysMenu) {
        sysMenuService.updateMenu(sysMenu);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
